package top.frsf.zombies;

import top.frsf.GamePanel;
import top.frsf.utils.GameState;

import java.awt.*;
import java.util.ArrayList;
import java.util.Random;

/**
 * @BelongsProject: MiniPZ
 * @BelongsPackage: top.frsf.zombies
 * @Author: FRSF
 * @CreateTime: 2022-09-10  15:40
 * @Description: 姜丝元素启动器
 * @Version: 1.0
 */
public class ZomStart {
    Random random = new Random();

    // zom列表
    public final ArrayList<ZomObject> zomList = new ArrayList<>();

    // 死亡zom
    public final ArrayList<ZomObject> deadZomList = new ArrayList<>();

    public void paintZom(Graphics g) {

        // 游戏开始
        if (GamePanel.stage == GameState.RUNNING) {
            if (GamePanel.fps % 500 == 1) {
                zomList.add(new NormalZom("", 850, 90 + 95 * random.nextInt(5),
                        90, 120));
            }

            zomList.removeAll(deadZomList);
            if (GamePanel.fps % 500 == 1)
                deadZomList.clear();

            for (ZomObject zom : zomList) {
                zom.paintSelf(g);
            }
        }
    }
}
